from manim import *


class axes(Scene):
    """ 
    显示二维坐标轴, 第1区间
    """
    def construct(self):
        ax = Axes(
            # x_range = [start: 起始值, end: 结束值, step: 步长],
            x_range=[0, 10, 1],
            y_range=[0, 20, 10],
            axis_config={
                "include_tip": False,   # 是否包含箭头
                "color": BLUE, # 颜色
            },
            x_axis_config={
                "numbers_to_include": np.arange(0, 10, 1), # 显示刻度值
                # "numbers_with_elongated_ticks": np.arange(0, 10, 1), # 突出显示刻度线
            },
            y_axis_config={
                "numbers_to_include": np.arange(0, 20, 10),
                # "numbers_with_elongated_ticks": np.arange(0, 100, 10),
            },
        )

        # 添加坐标轴标签
        axis_labels = ax.get_axis_labels()
        
        # 创建函数
        graph = ax.plot(lambda x: x*2, color=GREEN)

        # 函数标签
        geaph_label = ax.get_graph_label(graph, label="y=2*x", direction=UP)
        self.add(ax, axis_labels)
        self.play(Create(graph))
        self.play(Create(geaph_label))
        self.wait(2)
        
